<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">
        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="request.location.label_es" var="label" />
                <f:loadBundle basename="request.location.message_es" var="message" />
                <script>
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>
        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form rendered="#{access.visit}"> 
                    <p:growl id="messages" showDetail="true"/>  
                    <div class="field" >
                        <h:outputText value="#{label.field1}" class="label"/>
                        <h:selectOneMenu id="id_sede"   value="#{request_location.id_sede}" required="#{param['required']=='true'}" requiredMessage="#{message.m22}"
                                         valueChangeListener="#{request_location.selectedLocation}" onchange="submit()" >
                            <f:selectItem itemLabel="" itemValue="0"/>
                            <f:selectItems value="#{university_locationFind.listItem(request_location.universityBeans.id)}"/>  
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>
                    <br/>
                    <!--INSERTAR-->
                    <h:commandButton value="#{label.button1}" action="#{request_location.insert}" rendered="#{access.add}" class="button" onclick="return verificar('#{message.m7}')"/>

                </h:form>
                <h:form>
                    <c:set var="list" value="#{request_locationFind.listByLoggedId}"/>
                    <h:dataTable var="p" value="#{list}" rendered="#{not empty list}" class="dataTable">

                        <h:column >
                            <h:commandLink class="deleteButton" actionListener="#{request_location.deleteById(p.id)}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">  #{label.field1}  </f:facet>  
                            <h:outputText value="  #{p.locationBeans.nombre}  "/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">  #{label.field3}  </f:facet>  
                            <h:outputText value="#{p.facultyBeans.nombre}"/>
                        </h:column>
                    </h:dataTable>
                </h:form>
            </h:body>
        </ui:define>

        <!--Segemento donde se define un texto de ayuda para que el usuario pueda utilizar el formulario del contenido-->
        <ui:define name="slideHelper">

        </ui:define>
    </ui:composition>
</html>
